
<div class="main_right_between">
<?php
    $count = 1;
    $reset = 1;
    $global = count($news);
    //echo count($news);
    echo "<input type='hidden' value='".$global."' id='countnews'/>";
    if($global == 1):
?>
	<div class="news_content">
        <?php if(!is_file("admin/".$news[0]['news_image_thumb'])):?>
            <img class="img_des" src="<?=_BASE_URL?>admin/assets/uploads/images/news/imgerr.jpg" style="border: 2px solid #fff" width="150px" height="150px" />
        <?php else:?>
            <img class="img_des" src="<?=_BASE_URL?>admin/<?=$news[0]['news_image_thumb']?>" style="border: 2px solid #fff" width="150px" height="150px" />
        <?php endif;?>
        <p class="news_title"><?= $this->_helper->limited_character(ucfirst($news[0]['news_title']), 40)?></p>

        <ul class="meta">
            <?php
                $created_time = strtotime($news[0]['news_created']);
                $created_time = date('d-m-Y', $created_time);
            ?>
            <li>Ngày đăng: <?=$created_time?></li>
            <li>Chuyên mục: <a href="<?=_BASE_URL?>index.php?module=news&slug=<?=$news[0]['pages_slug']?>" style="color: #0CADAD;"><?=ucfirst($pages_name)?></a></li>
            <li>Lượt xem: <?=$news[0]['news_counter']?></li>
        </ul>

        <div class="main_news">
            <?= ucfirst($news[0]['news_content'])?>
        </div>
    </div><!--End of .news_content -->

<?php
    else:
        if(!empty($news)):
            foreach($news as $new):

                if($count == 9):
                    $count = 1;
                    $reset++;
                endif;

                if($count == 1):
                    if($reset == 1):
                        echo "<div id='p".$reset."' class='page _current' style=''>";
                    else:
                        echo "<div id='p".$reset."' class='page' style='display: none'>";
                    endif;
                endif;

                if($count < 5):
?>
                <div class="new_big">
                	<div class="new_img">
                        <?php if(is_file("admin/".$new['news_image_thumb'])):?>
                    	    <a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>"><img width="173px" height="117px" style="border: 1px solid #fff;" src="<?= _BASE_URL?>admin/<?=$new['news_image_thumb']?>" /></a>
                        <?php else:?>
                            <a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>"><img width="173px" height="117px" style="border: 1px solid #fff;" src="<?= _BASE_URL?>admin/assets/uploads/images/news/imgerr.jpg" /></a>
                        <?php endif;?>
                	</div>
                    <div class="new_big_text">
                    	<div class="text_h">
                        	<a style="color: #80F2F3!important;" href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>"><?= $this->_helper->limited_word(ucfirst($new['news_title']), 10) ?></a>
                        </div><!--End of .text_h -->

                            <div style="clear:both"></div>
                            <ul class="meta" style="margin: 10px 0;">
                                <?php if($new['news_updated'] != ''):?>
                                    <?php
                                        $news_updated = strtotime($new['news_updated']);
                                        $news_updated = date('d-m-Y', $news_updated);
                                    ?>
                                    <li>Ngày đăng: <?=$news_updated?></li>
                                <?php else:?>
                                    <?php
                                        $news_created = strtotime($new['news_created']);
                                        $news_created = date('d-m-Y', $news_created);
                                    ?>
                                    <li>Ngày đăng: <?=$news_created?></li>
                                <?php endif;?>


                                <li>Chuyên mục: <a href="<?= _BASE_URL?>index.php?module=news&slug=<?=$new['pages_slug']?>" style="color: #0CADAD;"><?=ucfirst($pages_name)?></a></li>
                                <li>Lượt xem: <?=$new['news_counter']?></li>
                            </ul><!--End of .meta -->
                        <div class="text_h1">
                            <?= $this->_helper->limited_word(strip_tags($new['news_content']), 50)?>
                        </div><!--End of .text_h1 -->
                        <a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>" class="text_h2">
                        	Chi Tiết
                        </a>
                    </div>
                    <?php unset($news[($count+(8*($reset-1))-1)]);?>
                </div><!-- End of .new_big-->

<?php
                else:
?>
                    <?php if($count == 5):?>
                        <ul class="other">
                            <li>
                            	<a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>" class="text_h1">
                            		  <?= $this->_helper->limited_word($new['news_title'], 10) ?>
                            	</a>
                                <?php unset($news[($count+(8*($reset-1))-1)]);?>
                            </li>
                    <?php elseif($count == 8 || $count == $global) :?>
                            <li>
                            	<a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>" class="text_h1">
                            		  <?= $this->_helper->limited_word($new['news_title'], 10) ?>
                            	</a>
                                <?php unset($news[($count+(8*($reset-1))-1)]);?>
                            </li>
                        </ul><!-- End of .other-->
                        </div>
                    <?php else:?>
                            <li>
                            	<a href="<?= _BASE_URL?>index.php?module=news&action=readnews&slug=<?=$new['slug']?>" class="text_h1">
                            		  <?= $this->_helper->limited_word($new['news_title'], 10) ?>
                            	</a>
                                <?php unset($news[($count+(8*($reset-1))-1)]);?>
                            </li>
                    <?php endif;?>
<?php
                endif;

                if($reset != 1 && (($count + 8*($reset-1)) == $global)):
                    echo "</div>";
                endif;

                $count++;

            endforeach;

        endif;
    endif;

?>

    <?php if($global != 1):?>
        <div style="clear: both;"></div>

        <div class="paging">
            <div class="newspaging" style="width: 315px; margin-left: 186px"></div>
        </div><!--End of #paging -->
    <?php endif;?>

	<div class="back"><a style="margin-bottom: 15px!important;" href="<?=_BASE_URL?>" title="Quay lại trang chủ">Back</a></div>
</div><!--End of .main_right_between -->


<script type="text/javascript">

   jQuery.noConflict();

   var countnews = jQuery('#countnews').val() ;
   var perpage = countnews/8;
   if(perpage<5)
   {
        perpage = 5;
   }

   jQuery(".newspaging").paginate({
				count 		: perpage,
				start 		: 1,
				display     : perpage,
				border					: false,
				text_color  			: '#888',
				background_color    	: '#EEE',
				text_hover_color  		: 'black',
				background_hover_color	: '#CFCFCF',
                mouse                   : 'press',
                onChange     			: function(page){
											jQuery('._current').removeClass('_current').hide();
											jQuery('#p'+page).addClass('_current').show();
										  }
	});

</script>

<script type="text/javascript">

    jQuery(".main_news").children().css("color", "#ccc");

</script>








